package com.oildatacollection.message;

import javafx.util.Pair;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class RecvMessage {
    private Map<String, Object> map;
    private Iterator<String> keyIter;

    public RecvMessage() {
        map = new HashMap<>();
        keyIter = null;
    }

    public void insertKV(String key, Object value) {
        map.put(key, value);
    }

    public Object getValue(String key) {
        return map.get(key);
    }

    public void resetIter() {
        keyIter = map.keySet().iterator();
    }

    public boolean hasNext() {
        return keyIter !=null && keyIter.hasNext();
    }

    public Pair<String, Object> getNext() {
        if (keyIter.hasNext()) {
            String key = keyIter.next();
            Object value = map.get(key);
            return new Pair<>(key, value);
        }
        return null;
    }

    public boolean IsEmpty() {
        return map.isEmpty();
    }

}
